#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2055;

int n, m;
int bit[N][N];
ll ibit[N][N], jbit[N][N], ijbit[N][N];
int lowbit(int x) { return x & -x; }
void update(int x, int y, ll d) {
  for (int i = x; i <= n; i += lowbit(i)) {
    for (int j = y; j <= m; j += lowbit(j)) {
      bit[i][j] += d;
      ibit[i][j] += x * d;
      jbit[i][j] += y * d;
      ijbit[i][j] += d * x * y;
    }
  }
}
ll query(int x, int y) {
  ll sum = 0, isum = 0, jsum = 0, ijsum = 0;
  for (int i = x; i > 0; i -= lowbit(i)) {
    for (int j = y; j > 0; j -= lowbit(j)) {
      sum += bit[i][j];
      isum += ibit[i][j];
      jsum += jbit[i][j];
      ijsum += ijbit[i][j];
    }
  }
  sum *= 1ll * (x + 1) * (y + 1);
  isum *= y + 1;
  jsum *= x + 1;
  return ijsum - isum - jsum + sum;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  char op;
  cin >> op >> n >> m;
  int a, b, c, d, delta;
  while (cin >> op) {
    if (op == 'L') {
      cin >> a >> b >> c >> d >> delta;
      update(a, b, delta);
      update(a, d + 1, -delta);
      update(c + 1, b, -delta);
      update(c + 1, d + 1, delta);
    } else {
      cin >> a >> b >> c >> d;
      ll sum = query(c, d);
      sum -= query(c, b - 1);
      sum -= query(a - 1, d);
      sum += query(a - 1, b - 1);
      cout << sum << endl;
    }
  }
  return 0;
}